﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using RecordBill.Dtos;
using RecordBill.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RecordBill.ViewModels
{
    public class BillOtherClassifyViewModel : BindableBase, IDialogAware
    {
        public string Title => "其他再分类";

        public event Action<IDialogResult> RequestClose;
        private List<Transaction> _listBillItems;

        public List<Transaction> ListBillItems
        {
            get => _listBillItems;
            set
            {
                _listBillItems = value;
                RaisePropertyChanged();
            }
        }
        public  List<UIComboxItem> ClassifyItems { get; set; }
        public bool CanCloseDialog()
        {
            return true;
        }
        public BillOtherClassifyViewModel()
        {
            ClassifyItems = PrismManager.ClassifyItems;
            SureCommand = new DelegateCommand(Sure);
        }
        public void OnDialogClosed()
        {
        }
        public DelegateCommand SureCommand { get; set; }

        private void Sure()
        {
            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
            if (!parameters.ContainsKey(PrismManager.OtherKey))
                return;
            ListBillItems = parameters.GetValue<List<Transaction>>(PrismManager.OtherKey);
        }
    }
}
